home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 21
/
Cream of the Crop 21 (Terry Blount) (October 1996).iso
/
program
/
tsfaqp34.zip
/
FAQPAS5.TXT
< prev
next >
Wrap
Text File
|
1996-09-14
|
5KB
|
126 lines
From ts@uwasa.fi Sat Sep 14 00:00:00 1996
Subject: FAQPAS5.TXT contents
Copyright (c) 1993-1996 by Timo Salmi
All rights reserved
FAQPAS5.TXT The fifth set of frequently (and not so frequently)
asked Turbo Pascal questions with Timo's answers. The items are in
no particular order.
You are free to quote brief passages from this file provided you
clearly indicate the source with a proper acknowledgment.
Comments and corrections are solicited. But if you wish to have
individual Turbo Pascal consultation, please post your questions to
a suitable Usenet newsgroup like news:comp.lang.pascal.borland. It
is much more efficient than asking me by email. I'd like to help,
but I am very pressed for time. I prefer to pick the questions I
answer from the Usenet news. Thus I can answer publicly at one go if
I happen to have an answer. Besides, newsgroups have a number of
readers who might know a better or an alternative answer. Don't be
discouraged, though, if you get a reply like this from me. I am
always glad to hear from fellow Turbo Pascal users.
....................................................................
Prof. Timo Salmi Co-moderator of news:comp.archives.msdos.announce
Moderating at ftp:// & http://garbo.uwasa.fi archives 193.166.120.5
Department of Accounting and Business Finance ; University of Vaasa
mailto:ts@uwasa.fi <URL:http://uwasa.fi/~ts> ; FIN-65101, Finland
--------------------------------------------------------------------
101) How do I detect if mouse hardware/driver is installed?
102) How can I read absolute sectors directly from a floppy?
103) How can I move a file to another directory in Turbo Pascal?
--------------------------------------------------------------------
From ts@uwasa.fi Sat Sep 14 00:01:41 1996
Subject: Detecting mouse
101. *****
Q: How do I detect if mouse hardware/driver is installed?
A: The source code is given below. For more mouse related functions
please see ftp://garbo.uwasa.fi/pc/programming/inter51c.zip for
interrupt $33 functions.
uses Dos;
(* Detect if mouse hardware/driver is installed; initializes driver *)
function MOUSDRFN : boolean;
var regs : registers;
begin
FillChar (regs, SizeOf(regs), 0); { Just to make sure }
regs.ax := $0000; { Interrupt function number }
Intr ($33, regs); { Call interrupt $33 }
if regs.ax = $FFFF then
mousdrfn := true
else mousdrfn := false;
end; (* mousedrfn *)
--------------------------------------------------------------------
From ts@uwasa.fi Sat Sep 14 00:01:42 1996
Subject: Reading absolute sectors
102. *****
Q: How can I read absolute sectors directly from a floppy?
A: Here is the source code for reading directly from a floppy disk.
For directly reading data from hard disk, please study the
information for interrupt $13 function $02 in Ralf Brown's list of
interrupts ftp://garbo.uwasa.fi/pc/programming/inter51a.zip.
uses Dos;
type readBufferType = array [1..1024] of byte;
procedure READFLPY (drive : char;
side : byte;
track : byte;
sector : byte;
var rb : readBufferType;
var ok : boolean);
var regs : registers;
i : byte;
begin
ok := false;
for i := 1 to 3 do begin
FillChar (regs, SizeOf(regs), 0); { Just to make sure }
regs.ah := $02; { Function }
regs.al := 2; { Number of sectors to read }
regs.dl := ord(Upcase(drive))-ord('A');
if (regs.dl < 0) or (regs.dl > 1) then exit; { For floppies only }
regs.dh := side;
regs.ch := track;
regs.cl := sector;
regs.es := Seg(rb);
regs.bx := Ofs(rb);
Intr ($13, regs); { Call interrupt $13 }
if regs.flags and FCarry = 0 then begin { Was it ok? }
ok := true; exit;
end; {if}
{ reset and try again a maximum of three times }
FillChar (regs, SizeOf(regs), 0); { Just to make sure }
regs.ah := $00; { Function }
regs.dl := ord(Upcase(drive))-ord('A');
end; {for i}
end; (* readflpy *)
--------------------------------------------------------------------
From ts@uwasa.fi Sat Sep 14 00:01:43 1996
Subject: Moving files
103. *****
Q: How can I move a file to another directory in Turbo Pascal?
A: If the file and the target directory are on the same disk you
can use Turbo Pascal's rename command for the purpose. If they are
on separate disks you'll first have to copy the file as explained in
the item "How can I copy a file in a Turbo Pascal program?" and then
erase the original as explained in the item "Can you tell a beginner
how to delete files with Turbo Pascal?"
var f : file;
begin
Assign (f, 'r:\faq.pas');
{$I-} Rename (f, 'r:\cmand\faq.pas'); {$I+}
if IOResult = 0 then
writeln ('File moved') else writeln ('File not moved');
end.
--------------------------------------------------------------------